package com.alibaba.dubbo.dynamic.service;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by wuyu on 2016/6/23.
 */
public interface BaseRest<T, Q, P> {

    @GetMapping(value = "/{id}")
    public T selectByPrimaryKey(@PathVariable("id") P id);

    @GetMapping(value = "/ids/{ids}")
    public List<T> selectByPrimaryKeys(@PathVariable("ids") List<P> ids);

    @GetMapping(value = "/list")
    public List<T> list(@RequestParam(value = "startNum", defaultValue = "0") Integer startNum, @RequestParam(value = "endNum", defaultValue = "10") Integer endNum);

    @DeleteMapping(value = "/{id}")
    public int deleteByPrimaryKey(@PathVariable("id") P id);

    @DeleteMapping(value = "/ids/{ids}")
    public int deleteByPrimaryKeys(@PathVariable("ids") List<P> ids);

    @PostMapping(value = "/insert", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object insert(@RequestBody T t);

    @PostMapping(value = "/", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object insertSelective(@RequestBody T t);

    @PostMapping(value = "/insertBatch", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object insertBatch(@RequestBody List<T> ts);

    @PutMapping(value = "/", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object updateByPrimaryKeySelective(@RequestBody T t);

}
